package org.xhnews.ui;

import java.io.UnsupportedEncodingException;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.browser.field2.BrowserFieldConfig;
import net.rim.device.api.ui.container.MainScreen;

import org.xhnews.to.RssItem;

public class RssDescriptionScreen extends MainScreen {
	BrowserField myBrowserField;

	public RssDescriptionScreen() {
		BrowserFieldConfig bfc = new BrowserFieldConfig();
		myBrowserField = new BrowserField(bfc);
		add(myBrowserField);

	}

	public void initialize(RssItem item) {
		String HTMLStr = "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><body>"
				+ "<div style=\"background:#E0EDF7; font-size:23px\">"
				+ item.getTitle()
				+ "</div>"
				+ "<p style=\"font-size:17px;\">"
				+ item.getDescription()
				+ "</p>"
				+ "<a href=\""
				+ item.getLink()
				+ "\"><div style=\"text-align:right"
				+ "\">"
				+ "查看全文"
				+ "</div></a><hr/>"
				+ "来源自 "
				+ item.getSource()
				+ "    " + item.getPubDate() + "</body></html>";
		try {
			myBrowserField.displayContent(HTMLStr.getBytes("utf-8"),
					"text/html; charset=utf-8", "http://localhost");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
